/**
 * Created by bing on 2020/3/14.
 */
package com.wxb.mybatis.intercept;

import org.apache.ibatis.executor.parameter.ParameterHandler;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;

import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Properties;

/**
 * describe:
 *
 * @author : wxbing
 * @date : 2020-03-14
 */
@Intercepts(
		@Signature(method = "setParameters",
				type = ParameterHandler.class,
				args = {PreparedStatement.class}
		)
)
public class MyParameterInterceptor implements Interceptor {

	@Override
	public Object intercept(Invocation invocation) throws Throwable {
		System.out.println("MyParameterInterceptor 被拦截方法执行之前，做的辅助服务······");
		Object proceed = invocation.proceed();
		System.out.println("MyParameterInterceptor 被拦截方法执行之后，做的辅助服务······");
		return proceed;
	}

	@Override
	public Object plugin(Object target) {
		return Plugin.wrap(target, this);
	}

	@Override
	public void setProperties(Properties properties) {

	}
}
